<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="vue.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="demo">
			<div>
				<!-- 输入框 输入时触发-->
				<input v-model.trim="message">
				<span>Message is: {{ message }}</span>
			</div>
			<div>
				<!-- 输入框 change触发 -->
				<input v-model.lazy="message3">
				<span>chagne事件触发 Message3 is: {{ message3 }}</span>
			</div>
			<div>
				<!-- 多行输入框 -->
				<textarea v-model="message2"></textarea>
				<span>多行文本：{{message2}}</span>
			</div>
			<!-- 复选框 -->
			<div>
				<input type="checkbox" name="tag" v-model="tags" id="tag1" value="tag1" />
				<label for="tag1">tag1</label>
				<input type="checkbox" name="tag" v-model="tags" id="tag2" value="tag2" />
				<label for="tag2">tag2</label>
				<p>复选框:{{tags}}</p>
			</div>
			<!-- 单选框 -->
			<div>
				<input type="radio" id="category1" name="category" v-model="category" value="category1" />
				<label for="category1">分类1</label>
				<input type="radio" id="category2" name="category" v-model="category" value="category2" />
				<label for="category2">分类2</label>
				<input type="radio" id="category3" name="category" v-model="category" value="category3" />
				<label for="category3">分类3</label>
				<p>单选框:{{category}}</p>
			</div>
			<!-- 下拉框单选 -->
			<div>
				<select v-model="selected">
					<option value="" disabled>请选择</option>
					<option v-for="item in options" v-bind:value="item.value">{{item.text}}</option>
				</select>
				<p>下拉框：{{selected}}</p>
			</div>
			<!-- 下拉框多选 -->
			<div>
				<select v-model="selected2" multiple="">
					<option value="" disabled>请选择</option>
					<option v-for="item in options" v-bind:value="item.value">{{item.text}}</option>
				</select>
				<p>下拉框：{{selected2}}</p>
			</div>
			<!-- 数值文本框 -->
			<div>
				<input v-model.number="total" type="number" />
			</div>
			<!-- 保存 -->
			<button type="button" @click="submit">提交</button>
		</div>
		<script type="text/javascript">
			var vm = new Vue({
				el: "#demo",
				data: {
					message: "",
					message2: "",
					message3: "",
					tags: [],
					category: "",
					selected: "",
					selected2: [],
					total: 0,
					options: [{
							value: "v1",
							text: "One"
						},
						{
							value: "v2",
							text: "Two"
						},
						{
							value: "v3",
							text: "Three"
						}
					]
				},
				methods: {
					submit: function() {
						var formData = {
							message: this.message,
							message2: this.message2,
							message3:this.message3,
							tags: this.tags,
							category: this.category,
							selected: this.selected,
							total: this.total
						};
						console.log(formData);
					}
				}
			});
		</script>
		<style type="text/css">
			#demo div {
				margin-top: 20px;
			}
		</style>
	</body>
</html>
